'''
Created on May 24, 2009

@author: user
'''
from cliques.potentialBasedSearch import potentialBasedSearch
import random

class cliqueStarSearch(potentialBasedSearch):
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
        potentialBasedSearch.__init__(self)
               
    def choose_node(self):
        max_kPc = None
        max_size = 0

        for kPc in self.pcdb:
            if len(kPc.core)>max_size or \
                (len(kPc.core)==max_size and len(kPc.gcn)>len(max_kPc.gcn)):
                max_size = len(kPc.core)
                max_kPc = kPc
               
        if max_kPc is not None:
            return max_kPc.gcn[random.randint(0,len(max_kPc.gcn)-1)]
        else:
            return self.generated[random.randint(0,len(self.generated)-1)]


    def __str__(self):
        return "cliqueStarSearch"
